<?php

namespace app\common\model;

class OrderProject extends BaseModel
{
    protected $jsonAssoc = true;
    protected $append = ['status_name'];
    protected $json = ['sign_info'];
    protected $type = [
        "device_info" => "array",
        "parts_info" => "array",
        "liu_time" => "timestamp"
    ];
    
    public function getStatusNameAttr($value,$data)
    {
        $temp = [
            2 => "已完成",
            -1 => "未结清",
            1 => "已结清",
        ];
        return $temp[$data['status']] ?? '';
    }

    public function factory()
    {
        return $this->belongsTo(Factory::class);
    }

    public function diggings()
    {
        return $this->belongsTo(Diggings::class);
    }
}